/**
 *  *2010-3-31 下午10:49:20  add 
 */
package com.base.myproject.client.busi.service;

import com.base.myproject.client.busi.BaseStoreEvent;
import com.base.myproject.client.busi.BaseStoreListener;
import com.base.myproject.client.busi.BaseStoreEvent.EventType;
import com.base.myproject.client.jdbc.DataSet;
import com.base.myproject.client.system.Env;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * 部门使用
 * @author Administrator
 *2010-3-31
 * javazgw@gmail.com
 */
public class BcodePanel_B extends BcodePanel{
	
	public BcodePanel_B()
	{
		super();
		mainsql = "select * from bcode where systemid in (select systemid from bcode where bcode='"+Env.getEnvbcode()+"')";
	
	//	init();
	}
	public void init()
	{
		
		super.init();
		store.addBaseStoreListener( EventType.ROW_ADDED, getBasestoreListener());
	}

		private BaseStoreListener getBasestoreListener()
		{
			BaseStoreListener listener = new BaseStoreListener()
			{

				@Override
				public void BaseStoreEventHandle(final BaseStoreEvent evt) {
					
					final int rowindex = evt.getBasestore().getCurcowindex();
					if(evt.getEventType().equals(BaseStoreEvent.EventType.ROW_ADDED))
					{
						 final com.base.myproject.client.tools.GreetingServiceAsync greetingService = GWT
							.create(com.base.myproject.client.tools.GreetingService.class);
					greetingService.getDataSet("select systemid from bcode where bcode='"+Env.getEnvbcode()+"'", new AsyncCallback<DataSet>(){

						@Override
						public void onFailure(Throwable caught) {
							
							
						}

						@Override
						public void onSuccess(DataSet result) {
							
							if(result.getRowCount()>0)
							{
								evt.getBasestore().setValue(rowindex, "systemid", result.getValue(0, "systemid"));
							}
						}
						
					});
					}
				}

				@Override
				public void onBrowserEvent(Event event) {
					
					
				}
			};
			return listener;
		}

	void initx()
	{
		groupicode_t =  com.base.myproject.client.ui.codenamemap.CodeNameMapFactory.createGroupInput_F_filter();
	}
	protected void setdefault()
	{
		//Env.get
		//getStore().addDefault("systemid", "001");
		getStore().addDefault("password", "666666");

	}
	protected void addnew()
	{
		super.addnew();
		
		
	}
}
